package com.skyger.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;

/**
 *
 * @author skyger  E-mail: jintianfan@gmail.com
 * @version v0.1.0 created：2013-5-23 下午9:40:59
 * 
 */
public class Application {
	private static Application app ;
	
	private Properties prop;
	
	private Application(){
		loadAppProperties();
	}
	
	public void loadAppProperties(){
		try {
		prop = new Properties();//属性集合对象 
	    InputStream path =new FileInputStream("res/app.properties");//获取路径并转换成流
	    	prop.load(path);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	public static  Application getApp(){
		if(app==null)
			app=new Application();
		return app;
	}
	
	public String getSetting(String key){
		return prop.getProperty(key);
	}
	
	public void setSetting(String key,String value){
		prop.setProperty(key, value);
		try {
			prop.store(new FileOutputStream("resources/app.properties"), "jin");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	/**
	 * 系统退出时调用
	 */
	private void persistentSettings(){
		
	}


	
}


